package zzzhc.image.ui;

import java.awt.Component;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

public class ImageListCellRender implements ListCellRenderer {

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		JLabel label = new JLabel();
		if (value == null) {
			return label;
		}
		BufferedImage image = (BufferedImage) value;
		label.setIcon(new ImageIcon(image));
		label.setSize(image.getWidth() + 10, image.getHeight() + 6);
		return label;
	}
}
